package ru.ifmo.ctd.ngp.theory.xdivk.onemax;

import ru.ifmo.ctd.ngp.learning.reinforce.AgentPrinter;
import ru.ifmo.ctd.ngp.learning.reinforce.DynaAgent;
import ru.ifmo.ctd.ngp.learning.reinforce.Environment;

public class DynaConsolePrinter<S, A> implements AgentPrinter<S, A, DynaAgent<S, A>> {
	private static DynaConsolePrinter<?, ?> instance = new DynaConsolePrinter<>();
	private DynaConsolePrinter() {}
	
	/**
	 * Gets the instance of this printer
	 * @return the instance of this printer
	 */
	@SuppressWarnings("unchecked")
    public static<S, A> DynaConsolePrinter<S, A> getInstance() {
		return (DynaConsolePrinter<S, A>) instance;
	}
	
	@SuppressWarnings("unchecked")
    public static <S, A> void addTo(DynaAgent<S, A> agent) {
		agent.addPrinter((DynaConsolePrinter<S, A>) instance);
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void print(DynaAgent<S, A> agent, Environment<? extends S, ? extends A> environment) {
		System.out.println("state received: " + environment.getCurrentState());
		System.out.println();
	}
}
